package com.jizhi.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jizhi.entity.Doctor;
import com.jizhi.entity.Drugstore;
import com.jizhi.service.DrugstoreService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 王书豪
 * @since 2020-11-17
 */
@RestController
@RequestMapping("/drugstore")
public class DrugstoreController {
    @Resource
    private DrugstoreService drugstoreService;

    @ApiOperation(value = "添加药品仓库信息", notes = "根据drugstore来添加药品仓库信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "drugstore", value = "药品仓库实体drugstore", required = true, dataType = "Drugstore"),
            @ApiImplicitParam(name = "number", value = "出入库的药品数量", required = true, dataType = "Integer",paramType = "path"),
            @ApiImplicitParam(name = "type", value = "出入库的类型", required = true, dataType = "String",paramType = "path"),
            @ApiImplicitParam(name = "jingbanren", value = "出入库的经办人", required = true, dataType = "String",paramType = "path")
    })
    @PostMapping("/getinert/{number}/{type}/{jingbanren}")
    public String getinert(@RequestBody Drugstore drugstore, @PathVariable("number") Integer number,@PathVariable("type") String type,@PathVariable("jingbanren") String jingbanren){
        int num=drugstoreService.insert(drugstore,number,type,jingbanren);
        if (num!=0){
            return "添加成功";
        }else {
            return "添加失败";
        }
    }
    @ApiOperation(value = "药品仓库药品数量不足30的信息（分页）", notes = "药品仓库药品数量不足30的信息（分页）")
    @ApiImplicitParam(name = "current", value = "在第几页的页码", required = true, dataType = "Integer",paramType = "path")
    @GetMapping("/fuilTjcx/{current}")
    @ResponseBody
    public Object fuilTjcx(@PathVariable("current")Integer current){
        Page<Object> page = new Page<>(current,2);
        List<Drugstore> doctorList = drugstoreService.selectTjcx(page);
        return doctorList;
    }
}

